package com.ruoyi.web.controller.orderManage;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.Unsubscribe;
import com.ruoyi.system.domain.Unsubscribe;
import com.ruoyi.system.service.UnsubscribeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/system/unsubscribe")
public class UnsubscribeController extends BaseController {

    @Autowired
    private UnsubscribeService unsubscribeService;


    @PreAuthorize("@ss.hasPermi('system:unsubscribe:list')")
    @GetMapping("/list")
    public TableDataInfo list(Unsubscribe unsubscribe)
    {
        startPage();
        List<Unsubscribe> list = unsubscribeService.selectUnsubscribeList(unsubscribe);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('system:unsubscribe:add')")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody Unsubscribe unsubscribe)
    {
        return toAjax(unsubscribeService.insertUnsubscribe(unsubscribe));
    }

    @PreAuthorize("@ss.hasPermi('system:unsubscribe:update')")
    @PostMapping("/update")
    public AjaxResult update(@RequestBody Unsubscribe unsubscribe)
    {
        return toAjax(unsubscribeService.updateUnsubscribe(unsubscribe));
    }

    @PreAuthorize("@ss.hasPermi('system:unsubscribe:delete')")
    @DeleteMapping("/delete")
    public AjaxResult delete(@RequestBody String numberId)
    {
        return toAjax(unsubscribeService.deleteUnsubscribe(numberId));
    }
}
